package com.netbao.sys.vomapper;

import com.netbao.sys.model.Resources;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface ResourceMapper {
    @Select("SELECT id,pid,cname,icon,url,isdel,ismenu,ismenu_leaf isMenuleaf FROM sys_resources WHERE ismenu=1 AND isstop=0 AND isdel=0 AND  id IN\n" +
            "(SELECT res_id FROM sys_role_res WHERE role_id IN\n" +
            "(SELECT role_id FROM sys_user_role WHERE user_id = #{userid})\n" +
            ")")
    List<Resources> getmenu(Integer userid);


    @Select("SELECT r.id,pid,cname,perms,icon,url,isleaf ismenuLeaf,IF(rr.res_id IS NULL,FALSE,TRUE) isdel FROM sys_resources r " +
            "LEFT JOIN sys_role_res rr ON(r.id=rr.res_id AND role_id=#{roleid})")
    List<Resources> getRolesidByRes(Long roleid);
}
